﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Dialog.Master" AutoEventWireup="true"
    CodeBehind="ReceiptInfoTrackEdit.aspx.cs" Inherits="NetDon.OA.Portal.Clerk.ReceiptInfoTrackEdit" %>

<%@ Import Namespace="NetDon.OA.Interface" %>
<%@ Import Namespace="NetDon.Utilities" %>
<%@ Register Src="../Controls/RequiredMark.ascx" TagName="RequiredMark" TagPrefix="uc1" %>
<%@ Register TagPrefix="uc2" TagName="ComanyDepartment" Src="~/Components/ProvinceCity.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .ProductView td.ItemContent DIV
        {
            width: 100%;
        }
    </style>
    <script language="javascript" type="text/javascript">

        $(document).ready(function () {
            var dialog;
            if (window.top == window) {
                dialog = window;
            } else {

                dialog = window.top.Page.Dialog.find(function (item) {
                    return item._contentFrame.contentWindow == window;
                });

            }
            var fieldId = $get('<%=this.fieldIds.ClientID %>');


            var reloadButton = $get('<%=btnReLoadIds.ClientID %>');
            if (dialog && !reloadButton.disabled) {

                $text(fieldId, dialog._context.dialogArguments.Ids);
                reloadButton.click();


            }
        });

        function deleteIssuingOrderDeliveryId(issuingOrderDeliveryId) {
            $confirm("确定要删除该回单异常信息吗？", function (result) {
                if (result == true) {
                    $text($get('<%=hiddenIssuingOrderReceiptTrackCommentId.ClientID%>'), issuingOrderDeliveryId);
                    $get('<%=btnhiddenIssuingOrderReceiptTrackCommentDelete.ClientID%>').click();
                }
            });
        }

        function onChangeGoodsDelayedReasons(obj, foucsControlId) {
            var goodsDelayedReasons = $(obj).val();
            if (goodsDelayedReasons.trim() != "") {

                $text($get('<%=hiddenReceiptInfoExceptions.ClientID%>'), goodsDelayedReasons);

                if (foucsControlId) {
                    setFocus(obj, foucsControlId);
                }
                $get('<%=btnReceiptInfoExceptions.ClientID%>').click();

            }

        }

        function calculateDelayedDays(object) {
            var start = $("#<%=this.txtReceiptInfoPlannedResponseDate.ClientID %>").text();
            var end = $("#<%=this.txtReceiptInfoActualResponseDate.ClientID %>").val();
            var re = /^(\d{4})\S(\d{1,2})\S(\d{1,2})$/;
            var startDate, endDate;
            if (re.test(start)) {
                startDate = new Date(RegExp.$1, RegExp.$2 - 1, RegExp.$3);

            }
            if (re.test(end)) {
                endDate = new Date(RegExp.$1, RegExp.$2 - 1, RegExp.$3);

            }
            if (startDate && endDate) {

                var dayInterval = (Math.floor((endDate - startDate) / (1000 * 60 * 60 * 24)));

                $("#<%=this.txtReceiptInfoDelayedDays.ClientID %>").val(dayInterval.toString());
                if (dayInterval > 0) {
                    $("#<%=this.txtReceiptInfoDelayedDays.ClientID %>").css("color", "#FF6600");

                }
            }
        }

        function calculateReceiptInfoPlannedResponseDate() {

            var startShippment = $("#<%=this.hiddenplannedGoodsDeliveryDate.ClientID %>").val();

            var startShippmentDate = new Date(Date.parse(startShippment.replace(/-/g, "/")));
            var unit = $("#<%=this.ddlReceiptInfoOnWayUnit.ClientID %>").val();
            if (startShippment && startShippmentDate) {
                var onwayDays = parseInt($("#<%=this.txtReceiptInfoOnWayDays.ClientID %>").val());
                if (onwayDays) {
                    if (unit == "0") {
                        DateAdd("d ", onwayDays, startShippmentDate);
                    } else {
                        DateAdd("h ", onwayDays, startShippmentDate);
                    }

                    $("#<%=this.txtReceiptInfoPlannedResponseDate.ClientID %>").text(startShippmentDate.format("yyyy-MM-dd"));
            
                }

            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:Panel ID="panelBasic" runat="server" DefaultButton="btnSave">
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td>
                    <NetDon:FormPanel ID="FormPanelBasicInfo" runat="server" CaptionAlign="NotSet" RepeatColumns="2"
                        SkinID="ProductView">
                        <Items>
                            <NetDon:FormItem FullRow="True" HeaderVisible="False">
                                <ContentTemplate>
                                    <asp:Literal ID="Literal3" runat="server" Text="基本信息"></asp:Literal>
                                </ContentTemplate>
                                <ContentStyle ForeColor="#037CC6" Font-Bold="true"></ContentStyle>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="订单编号">
                                <ContentTemplate>
                                    <asp:Label runat="server" ID="txtOrderCode" Text='<%# Eval("OrderCode") %>'>	</asp:Label>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="回单状态">
                                <ContentTemplate>
                                    <asp:Label runat="server" ID="txtOrderStatus" Text='<%# EnumUtilities.GetDescription((OrderStatus)Enum.Parse(typeof(OrderStatus), Eval("OrderStatus").ToString())) %>'>	</asp:Label>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="客户">
                                <ContentTemplate>
                                    <asp:Label runat="server" ID="Label1" Text='<%#GetCustomerName(Eval("CustomerId")) %>'>	</asp:Label>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="承运货物">
                                <ContentTemplate>
                                    <asp:Label runat="server" ID="Label2" Text='<%#GetDictionaryItemName(Eval("GoodsShippedTypeId")) %>'>	</asp:Label>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="线路分类">
                                <ContentTemplate>
                                    <asp:Label runat="server" ID="Label3" Text='<%#GetDictionaryItemName(Eval("RouteTypeId")) %>'>	</asp:Label>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="出单日期">
                                <ContentTemplate>
                                    <asp:Label ID="Label44" Text='<%#Eval("ReceivingOrderDate") != null ? ((DateTime)Eval("ReceivingOrderDate")).ToString("yyyy-MM-dd") : ""%>'
                                        runat="server"></asp:Label>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="运输计划号">
                                <ContentTemplate>
                                    <asp:Label ID="Label344" Text='<%#Bind("TransportationPlanCode") %>' runat="server"></asp:Label>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="下单数量">
                                <ContentTemplate>
                                    <asp:Label ID="Label6"   Text='<%#Convert.ToDecimal(Eval("OrderQuantity")).ToString("#,###.00")%>' runat="server"></asp:Label>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="下单材积（方）">
                                <ContentTemplate>
                                    <asp:Label ID="Label7" Text='<%#Convert.ToDecimal(Eval("OrderVolumn")).ToString("#,###.000")%>'
                                        runat="server"></asp:Label>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="下单重量">
                                <ContentTemplate>
                                    <asp:Label ID="Label4" Text='<%#Convert.ToDecimal(Eval("OrderWeight")).ToString("#,###.000")%>'
                                        runat="server"></asp:Label>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="送货城市">
                                <ContentTemplate>
                                    <asp:Label ID="lblDeliveryCity" runat="server"></asp:Label>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="送货地点">
                                <ContentTemplate>
                                    <asp:Label ID="lblDeliveryAdress" runat="server"></asp:Label>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="交货单号" Key="DeliveryOrderCode" ColumnSpan="2">
                                <ContentTemplate>
                                    <asp:Label ID="lblDeliveryOrderCode" runat="server"></asp:Label>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="司机信息" ColumnSpan="2" Key="tt">
                                <ContentTemplate>
                                    <NetDon:GridView ID="GridViewDriverInfo" runat="server" AutoGenerateColumns="False"
                                        DataKeyNames="Id" CssClass="IncrementalTable">
                                        <Columns>
                                            <NetDon:IndexField HeaderText="序号">
                                            </NetDon:IndexField>
                                            <NetDon:TemplateField HeaderText="姓名">
                                                <ItemTemplate>
                                                    <asp:Label ID="Label11" Text='<%#Eval("DriverName") %>' runat="server"></asp:Label>
                                                    <br />
                                                </ItemTemplate>
                                            </NetDon:TemplateField>
                                            <NetDon:TemplateField HeaderText="电话">
                                                <ItemTemplate>
                                                    <asp:Label ID="Label21" Text='<%#Eval("DriverTelephone") %>' runat="server"></asp:Label>
                                                    <br />
                                                </ItemTemplate>
                                            </NetDon:TemplateField>
                                            <NetDon:TemplateField HeaderText="车牌号">
                                                <ItemTemplate>
                                                    <asp:Label ID="Label31" Text='<%#Eval("VehicleNumber") %>' runat="server"></asp:Label>
                                                    <br />
                                                </ItemTemplate>
                                            </NetDon:TemplateField>
                                        </Columns>
                                    </NetDon:GridView>
                                </ContentTemplate>
                            </NetDon:FormItem>
                        </Items>
                    </NetDon:FormPanel>
                </td>
            </tr>
            <tr>
                <td>
                    <NetDon:FormPanel ID="FormPanelIssuringOrderInfo" runat="server" CaptionAlign="NotSet"
                        RepeatColumns="2">
                        <Items>
                            <NetDon:FormItem FullRow="True" HeaderVisible="False">
                                <ContentTemplate>
                                    <asp:Literal ID="Literal1" runat="server" Text="回单信息"></asp:Literal>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="回单张数">
                                <ContentTemplate>
                                    <asp:TextBox ID="txtReceiptInfoCopies" Text='<%#Bind("ReceiptInfoCopies") %>' runat="server"
                                        Width="60px" MaxLength="9"></asp:TextBox>
                                    <uc1:RequiredMark ID="RequiredMark2" runat="server" />
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtReceiptInfoCopies"
                                        Display="None" ErrorMessage="请输入回单张数" SetFocusOnError="True"></asp:RequiredFieldValidator>
                                    <NetDon:NumericEditExtender ID="NumericEditExtender6" runat="server" MinValue="0"
                                        MaxValue="100000" TargetControlID="txtReceiptInfoCopies" DataMode="Integer">
                                    </NetDon:NumericEditExtender>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="回单在途天数">
                                <ContentTemplate>
                                    <asp:TextBox ID="txtReceiptInfoOnWayDays" Text='<%#Bind("ReceiptOnWayDays") %>' runat="server"
                                        Width="40px" MaxLength="9" ></asp:TextBox>
                                    <asp:DropDownList runat="server" ID="ddlReceiptInfoOnWayUnit" Width="80px" >
                                        <asp:ListItem Text="天" Value="0" Selected="True"></asp:ListItem>
                                        <asp:ListItem Text="小时" Value="1"></asp:ListItem>
                                    </asp:DropDownList>
                                      <uc1:RequiredMark ID="RequiredMark4" runat="server" />
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtReceiptInfoOnWayDays"
                                        Display="None" ErrorMessage="请输入回单在途天数" SetFocusOnError="True"></asp:RequiredFieldValidator>
                                    <NetDon:NumericEditExtender ID="NumericEditExtender1" runat="server" MaxValue="100000"
                                        TargetControlID="txtReceiptInfoOnWayDays" DataMode="Integer">
                                    </NetDon:NumericEditExtender>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="回单应回日期">
                                <ContentTemplate>
                                    <asp:Label ID="txtReceiptInfoPlannedResponseDate" Width="100px" Text='<%#Eval("ReceiptInfoPlannedResponseDate") != null ? ((DateTime)Eval("ReceiptInfoPlannedResponseDate")).ToString("yyyy-MM-dd") : ""%>'
                                        runat="server"></asp:Label>
                                    <%--  <uc1:RequiredMark ID="markStoreCode" runat="server" />
                                    <asp:CalendarExtender ID="txtPlannedShippingDateCalendarExtender1" runat="server"
                                        Animated="False" Enabled="True" FirstDayOfWeek="Sunday" TargetControlID="txtReceiptInfoPlannedResponseDate"
                                        Format="yyyy-MM-dd">
                                    </asp:CalendarExtender>
                                    <asp:CustomValidator ID="txtPlannedShippingDateCustomValidator1" ClientValidationFunction="validateDateText"
                                        runat="server" ErrorMessage="回单应回日期无效." Display="None" ControlToValidate="txtReceiptInfoPlannedResponseDate"
                                        OnServerValidate="DateValidator_ServerValidate"></asp:CustomValidator>
                                    <asp:RequiredFieldValidator ID="rfvStoreCode" runat="server" ControlToValidate="txtReceiptInfoPlannedResponseDate"
                                        Display="None" ErrorMessage="请输入回单应回日期" SetFocusOnError="True"></asp:RequiredFieldValidator>--%>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="回单实回日期">
                                <ContentTemplate>
                                    <asp:TextBox ID="txtReceiptInfoActualResponseDate" runat="server" Text='<%#Eval("ReceiptInfoActualResponseDate") != null ? ((DateTime)Eval("ReceiptInfoActualResponseDate")).ToString("yyyy-MM-dd") : ""%>'
                                        Width="100px"></asp:TextBox>
                                    <asp:CalendarExtender ID="txtReceiptInfoActualResponseDate_CalendarExtender1" runat="server"
                                        Animated="False" Enabled="True" FirstDayOfWeek="Sunday" TargetControlID="txtReceiptInfoActualResponseDate"
                                        Format="yyyy-MM-dd">
                                    </asp:CalendarExtender>
                                    <asp:CustomValidator ID="CustomValidator1" ClientValidationFunction="validateDateText"
                                        runat="server" ErrorMessage="回单实回日期无效." Display="None" ControlToValidate="txtReceiptInfoActualResponseDate"
                                        OnServerValidate="DateValidator_ServerValidate"></asp:CustomValidator>
                                    <%--  <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtReceiptInfoActualResponseDate"
                                        Display="None" ErrorMessage="请输入回单实回日期" SetFocusOnError="True"></asp:RequiredFieldValidator>--%>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="未回回单跟踪" ColumnSpan="2">
                                <ContentTemplate>
                                    <asp:TextBox ID="txtReceiptInfoNotReceived" runat="server" Text='<%#Bind("ReceiptInfoNotReceived") %>'
                                        Height="120px" Width="450px" TextMode="MultiLine"></asp:TextBox>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="回单迟到天数">
                                <ContentTemplate>
                                    <asp:TextBox ID="txtReceiptInfoDelayedDays" Text='<%#Convert.ToInt32(Eval("ReceiptInfoDelayedDays")).ToString("#,###")%>'
                                        runat="server" MaxLength="9" BorderStyle="None" ReadOnly="True"></asp:TextBox>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="是否延迟">
                                <ContentTemplate>
                                    <%#!MiscUtilities.IsNullOrEmpty(Eval("IsReceiptInfoDelayed")) && Convert.ToBoolean(Eval("IsReceiptInfoDelayed")) ? "是" : "否"%>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="是否异常" ColumnSpan="2">
                                <ContentTemplate>
                                    <asp:DropDownList ID="ddlIsReceiptInfoExceptional" runat="server" DataSourceID="EnumDataSourceIsReceiptInfoExceptional"
                                        DataTextField="Description" DataValueField="Name" Width="60px">
                                    </asp:DropDownList>
                                    <NetDon:EnumDataSource ID="EnumDataSourceIsReceiptInfoExceptional" EmptyItemType="None"
                                        runat="server" TypeName="NetDon.OA.Interface.YesOrNo">
                                    </NetDon:EnumDataSource>
                                </ContentTemplate>
                            </NetDon:FormItem>
                            <NetDon:FormItem HeaderText="回单异常信息" ColumnSpan="2">
                                <ContentTemplate>
                                    <NetDon:GridView ID="gridOrderDetailList" runat="server" AutoGenerateColumns="False"
                                        OnRowDataBound="gridIssuingOrderDelivery_RowDataBound" DataKeyNames="Id" CssClass="IncrementalTable">
                                        <Columns>
                                            <NetDon:IndexField HeaderText="序号">
                                            </NetDon:IndexField>
                                            <NetDon:TemplateField HeaderText="回单短少货损等异常跟踪">
                                                <ItemTemplate>
                                                    <asp:TextBox ID="txtReceiptInfoExceptions" Text='<%#Eval("ReceiptInfoExceptions")%>'
                                                        Height="50px" Width="200px" TextMode="MultiLine" SkinID="TextBoxArea" runat="server"></asp:TextBox>
                                                    <br />
                                                </ItemTemplate>
                                            </NetDon:TemplateField>
                                            <NetDon:TemplateField HeaderText="备注">
                                                <ItemTemplate>
                                                    <asp:TextBox ID="txtRemark" Text='<%#Eval("Remark") %>' SkinID="TextBoxArea" TextMode="MultiLine"
                                                        Height="50px" Width="200px" runat="server">
                                                    </asp:TextBox>
                                                </ItemTemplate>
                                            </NetDon:TemplateField>
                                            <NetDon:TemplateField HeaderText="操作" ItemStyle-Width="30px">
                                                <ItemTemplate>
                                                    <asp:ImageButton ID="btnDelete" runat="server" CausesValidation="false" SkinID="Delete" />
                                                </ItemTemplate>
                                            </NetDon:TemplateField>
                                        </Columns>
                                    </NetDon:GridView>
                                </ContentTemplate>
                            </NetDon:FormItem>
                        </Items>
                    </NetDon:FormPanel>
                </td>
            </tr>
            <tr>
                <td style="padding-left: 150px">
                    <asp:Button ID="btnSave" runat="server" SkinID="Button80" Text="保存" OnClick="btnSave_Click" />
                    <asp:Button ID="btnCancel" runat="server" SkinID="Button80" Text="取消" CausesValidation="false" />
                    <NetDon:ValidationSummary ID="ValidationSummary2" runat="server" ShowMessageBox="true"
                        ShowSummary="false" />
                </td>
            </tr>
            <tr>
                <td style="padding-left: 150px; padding-top: 4px;">
                    <asp:Button ID="btnSaveAndNext" runat="server" SkinID="Button120" OnClick="btnSaveAndNext_Click"
                        Text="保存并编辑下一个" />
                    <asp:Button ID="btnNext" runat="server" SkinID="Button80" Text="下一个" OnClick="btnNext_Click"
                        CausesValidation="False" />
                    <asp:Button ID="btnPrevious" runat="server" SkinID="Button80" Text="上一个" OnClick="btnPrevious_Click"
                        CausesValidation="False" />
                    <asp:Button ID="btnSaveAndPrevious" runat="server" SkinID="Button120" OnClick="btnSaveAndPrevious_Click"
                        Text="保存并编辑上一个" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:HiddenField ID="fieldIds" runat="server" />
    <asp:HiddenField ID="hiddenplannedGoodsDeliveryDate" runat="server" />
    
    
    <asp:Button ID="btnReLoadIds" runat="server" SkinID="Hidden" OnClick="btnReLoadIds_Click"
        CausesValidation="false" />
    <asp:HiddenField ID="hiddenIssuingOrderReceiptTrackCommentId" runat="server" />
    <asp:Button ID="btnhiddenIssuingOrderReceiptTrackCommentDelete" runat="server" SkinID="Hidden"
        CausesValidation="false" OnClick="btnhiddenIssuingOrderReceiptTrackCommentDelete_Click">
    </asp:Button>
    <asp:Button ID="btnReceiptInfoExceptions" runat="server" SkinID="Hidden" CausesValidation="false"
        OnClick="btnReceiptInfoExceptions_Click"></asp:Button>
    <asp:HiddenField ID="hiddenReceiptInfoExceptions" runat="server" />
</asp:Content>
